CC = /usr/bin/gcc
NVCC = /usr/local/cuda-12.8/bin/nvcc -ccbin /usr/local/bin/mpicxx
NVCCFLAGS = -Xcompiler -g -w -I.. --std=c++11 -gencode arch=compute_120,code=sm_120 -arch=sm_120
MPI = -I /usr/local/include
LIB = -L /usr/local/lib -L /usr/local/cuda/lib64/stubs -L /usr/local/cuda/lib64 -lmpi
EXTRA_LIBS=/usr/local/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs

BINS:= multiple

multiple: multiple.cu
	${NVCC} ${NVCCFLAGS} ${MPI} ${LIB} multiple.cu -o multiple


test_small_1: $(BINS)
	@mpiexec -n 4 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 4 512 small_input_data_3_1.txt
test_small_2: $(BINS)
	@mpiexec -n 3 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 1 512 small_input_data_3_3.txt
test_small_3: $(BINS)
	@mpiexec -n 4 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 1 512 small_input_data_3_5.txt

test_large_1: $(BINS)
	@mpiexec -n 2 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 4 128 large_input_data_200_10.txt
test_large_2: $(BINS)
	@mpiexec -n 3 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 2 64 large_input_data_299_29.txt
test_large_3: $(BINS)
	@mpiexec -n 4 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 1 512 large_input_data_599_3.txt

test: $(BINS)
	@mpiexec -n 2 -x LD_LIBRARY_PATH=${EXTRA_LIBS}:$LD_LIBRARY_PATH ./multiple 2 128 test.txt

clean:
	-rm multiple


